home *** CD-ROM | disk | FTP | other *** search
- class smashing.keithm.ViewportGroup
- {
- var name;
- var mcs;
- var index;
- var numSlots;
- var sortAxis;
- var ascending;
- var reverse;
- var scrollport;
- var min;
- var max;
- var current;
- var isSearching;
- var loop;
- function ViewportGroup(t_data)
- {
- this.name = t_data.name;
- this.mcs = [];
- this.index = t_data.index;
- this.numSlots = t_data.slots;
- if(t_data.sortAxis == undefined)
- {
- t_data.sortAxis = "";
- }
- this.sortAxis = t_data.sortAxis;
- if(this.sortAxis != "" && this.numSlots < 10000)
- {
- this.numSlots = 10000;
- }
- if(t_data.ascending == undefined)
- {
- t_data.ascending = false;
- }
- this.ascending = t_data.ascending;
- if(t_data.reverse == undefined)
- {
- t_data.reverse = false;
- }
- this.reverse = t_data.reverse;
- if(t_data.scrollport == undefined)
- {
- t_data.scrollport = false;
- }
- this.scrollport = t_data.scrollport;
- }
- function init(t_depth)
- {
- this.min = t_depth;
- this.max = t_depth + this.numSlots;
- this.reset();
- return this.max;
- }
- function reset()
- {
- this.mcs = [];
- if(this.reverse)
- {
- this.current = this.max;
- }
- else
- {
- this.current = this.min;
- }
- }
- function requestDepthChange(t_element)
- {
- t_element.mc.swapDepths(this.__getChangedDepth(t_element));
- }
- function requestDepthSort()
- {
- trace("Request Depth Sort not implemented yet. Better get to work!");
- }
- function getDepth(t_depth)
- {
- if(this.sortAxis != "")
- {
- return this.__getNewDepth(t_depth);
- }
- this.increment();
- return this.current;
- }
- function increment()
- {
- this.isSearching = true;
- while(this.isSearching)
- {
- if(this.reverse)
- {
- this.current = this.current - 1;
- if(this.current < this.min)
- {
- this.current = this.max;
- }
- }
- else
- {
- this.current = this.current + 1;
- if(this.current > this.max)
- {
- this.current = this.min;
- }
- }
- this.isSearching = false;
- this.loop = this.mcs.length;
- while(this.loop--)
- {
- if(this.mcs[this.loop].depth == this.current)
- {
- this.isSearching = true;
- this.loop = 0;
- }
- }
- }
- }
- function __getNewDepth(depth)
- {
- if(depth < 0)
- {
- trace("Error : Depth cannot be under zero");
- return undefined;
- }
- if(this.ascending)
- {
- depth = this.min + Math.ceil(depth);
- }
- else
- {
- depth = this.max - Math.ceil(depth);
- }
- this.loop = this.mcs.length;
- while(this.loop--)
- {
- if(this.mcs[this.loop].depth == depth)
- {
- if(this.ascending)
- {
- depth = depth + 1;
- }
- else
- {
- depth = depth - 1;
- }
- this.loop = this.mcs.length;
- }
- }
- return depth;
- }
- function __getChangedDepth(t_element)
- {
- var _loc2_ = Math.ceil(t_element[this.sortAxis]);
- if(_loc2_ < 0)
- {
- trace("Error : Depth cannot be under zero");
- return undefined;
- }
- if(this.ascending)
- {
- _loc2_ = this.min + _loc2_;
- }
- else
- {
- _loc2_ = this.max - _loc2_;
- }
- var _loc3_ = -1;
- this.loop = this.mcs.length;
- while(this.loop--)
- {
- if(this.mcs[this.loop].mc == t_element.mc)
- {
- _loc3_ = this.loop;
- }
- else if(this.mcs[this.loop].depth == _loc2_)
- {
- if(this.ascending)
- {
- _loc2_ = _loc2_ + 1;
- }
- else
- {
- _loc2_ = _loc2_ - 1;
- }
- this.loop = this.mcs.length;
- }
- }
- this.mcs[_loc3_].depth = _loc2_;
- return _loc2_;
- }
- }
-